package data.deal;

import java.io.File;
import java.io.IOException;
import java.sql.SQLException;

import util.DateUtil;
import data.LoadData;
import data.SaveHistoryData;
import dataconnect.InsertStockDeal;

public class AutoBak {
	public static void main(String[] args) {
		
		LoadData ld = new LoadData();
		ld.loadAllData();
		
		long t = System.currentTimeMillis();
		File file = new File("historydata"+File.separator+"last.sto");
		String fileName = DateUtil.format(DateUtil.getThisDate());
		File file2 = new File("historydata"+File.separator+fileName+".sto");
		try {
			if(file.exists()){
				file.delete();
			}
			if(file2.exists()){
				file2.delete();
			}
			new SaveHistoryData().saveHistoryData();
			System.out.println("save file:"+(System.currentTimeMillis()-t));
			InsertStockDeal.insertStockData(fileName+".sto");
		} catch (IOException ioe) {
			ioe.printStackTrace();
		} catch (SQLException sqle) {
			sqle.printStackTrace();
		}
		long t2 = System.currentTimeMillis();
		System.out.println("备份完成:"+(t2-t));
		System.exit(0);
	}
}
